<?php
include("config.php");
if(!isset($_POST['Username'])) die ("Username is blank!!");
if(!isset($_POST['Password'])) die ("Password field is blank!!");
session_start();
mysql_connect($DBHOST, $DBUSERNAME, $DBPASSWORD);
mysql_select_db($DBNAME);
$query = mysql_query('SELECT * from Members WHERE Username = '$_POST['Username\']' AND Password = '$_POST['Password\']');
if($query) {
		if(mysql_num_rows($query) == 1) {
			// Login Queries //
			session_regenerate_id();
			$member = mysql_fetch_assoc($query);
			$_SESSION['SESS_MEMBER_ID'] = $member['MemberID'];
			$_SESSION['SESS_USER_LEVEL'] = $member['userlevel'];
			session_write_close();
			header("location: area.php");
			exit();
		}
	else {
		die("Something went wrong! Either your Username or Password is incorrect, or there is a server-side Databae Problem!");
	}
?>